﻿
$(document).ready(function () {
    //Config tab and date picker
    $("#componentTabs").tabs();
    $(".shipDate").datepicker({ minDate: 15 });

    //Show hide control
    var componentType = $('input[name=componentType]:checked', '#frmShippingSimplex').val();
    showHideControls(componentType)
    // Handle check box checkTruckWithLiftGate
    $("#checkTruckWithLiftGate").click(function () {
        if ($(this).prop('checked') == true) {
            $("#labelForCheckTruckWithLiftGate").removeAttr("class");
        } else {
            $("#labelForCheckTruckWithLiftGate").attr("class","inactive");
        }
    });
    // Handle checkbox checkAdvancedNotice
    $("#checkAdvancedNotice").click(function () {
        if ($(this).prop('checked') == true) {
            $("#labelForCheckAdvancedNotice").removeAttr("class");
            $("#contactName").attr("class","label-wrap wd_200");
            $("#contactPhone").attr("class","label-wrap wd_200");
            $("#contactNameInput").removeAttr("readonly");
            $("#contactPhoneInput").removeAttr("readonly");
            $("#contactNameInput").attr("class","mce");
            $("#contactPhoneInput").attr("class", "mce");
        } else {
            $("#labelForCheckAdvancedNotice").removeAttr("class", "inactive");
            $("#contactName").attr("class", "label-wrap wd_200 inactive");
            $("#contactPhone").attr("class", "label-wrap wd_200 inactive");
            $("#contactNameInput").attr("readonly", "readonly");
            $("#contactPhoneInput").attr("readonly", "readonly");
            $("#contactNameInput").attr("class", "mce disabled");
            $("#contactPhoneInput").attr("class", "mce disabled");
            $("#contactNameInput").val("");
            $("#contactPhoneInput").val("");
        }
    });
});

function showHideControls(componentType) {
    if (componentType == 1) {
        //Same location
        $("#addressInfoSameLocation").show();
        $("#addressInfoDifferenceLocation").hide();
        $("#labelForRdoSameLocationShipped").removeAttr("class");
        $("#labelForRdoDifferenceLocationShipped").attr("class", "inactive");

    } else {
        //Difference location
        $("#addressInfoSameLocation").hide();
        $("#addressInfoDifferenceLocation").show();
        $("#labelForRdoSameLocationShipped").attr("class", "inactive");
        $("#labelForRdoDifferenceLocationShipped").removeAttr("class");
    }
}

function clearAllShippingDetail() {
    $(".shippingName").val("");
    $(".shipDate").val("");
    $(".shippingStreet").val("");
    $(".shippingCity").val("");
    $(".shippingZip").val("");
}

function showHideFreightOptionSelector(selector) {
    if (selector == 1) {
        //MCE Selector
        $("#labelRdoMceSelected").removeAttr("class");
        $("#labelRdoCustomerSelected").attr("class", "inactive");
        $("#carrierOrFreightForwarder").attr("class", "label-wrap wd_200 inactive");
        $("#carrierOrFreightForwarderInput").attr("class", "mce disabled");
        $("#carrierOrFreightForwarderInput").attr("readonly", "readonly");
        
        $("#shippingAccountNumber").attr("class", "label-wrap wd_200 inactive");
        $("#shippingAccountNumberInput").attr("class", "mce disabled");
        $("#shippingAccountNumberInput").attr("readonly", "readonly");
        $("#noteForExpeditedShipping").attr("class", "inactive");
        $("#carrierOrFreightForwarderInput").val("");
        $("#shippingAccountNumberInput").val("");
    } else {
        //MCE Selector
        $("#labelRdoCustomerSelected").removeAttr("class");
        $("#labelRdoMceSelected").attr("class", "inactive");
        $("#carrierOrFreightForwarder").attr("class", "label-wrap wd_200");
        $("#carrierOrFreightForwarderInput").attr("class", "mce");
        $("#carrierOrFreightForwarderInput").removeAttr("readonly");

        $("#shippingAccountNumber").attr("class", "label-wrap wd_200");
        $("#shippingAccountNumberInput").attr("class", "mce");
        $("#shippingAccountNumberInput").removeAttr("readonly");
        $("#noteForExpeditedShipping").removeAttr("class");
    }
}